package com.www.dao.admin;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import com.www.domain.admin.Floor;

/**
 * 楼层dao
 */
@Repository
public interface FloorDao {
	/*
	 * 楼层插入操作 
	 */
	@Insert("insert into floor(id,name,remark) values(default,#{name},#{remark})")
	public int add(Floor floor);
	
	/*
	 * 楼层编辑操作
	 */
	@Update("update floor set name = #{name},remark = #{remark} where id = #{id}")
	public int edit(Floor floor);
	
	/*
	 * 删除楼层信息
	 */
	@Delete("delete from floor where id = ${value}")
	public int delete(Long id);
	
	/*
	 * 楼层信息搜索查询 
	 */
	@Select({"<script>" +
			"select * from floor " +
			"<if test='name != null'> where name like '%${name}%'</if>" +
			"<if test='offset != null and pageSize != null'> limit #{offset},#{pageSize}</if>" +
		"</script>"})
	public List<Floor> findList(Map<String, Object> queryMap);
	
	/*
	 * 获取所有楼层信息 
	 */
	@Select("select * from floor")
	public List<Floor> findAll();
	
	/*
	 *  模糊搜索总条数 
	 */
	@Select({"<script>" +
			"select count(*) from floor " +
			"<if test='name != null'> where name like '%${name}%'</if>" +
		"</script>"})
	public Integer getTotal(Map<String, Object> queryMap);
}
